package com.danco.training.zaneuskaya.domain.comparator;

import java.io.Serializable;
import java.util.Comparator;

import com.danco.training.zaneuskaya.domain.entity.Book;

public class BookComparatorByPrice implements Comparator<Book>,Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1792687991478632197L;

	public int compare(Book o1, Book o2) {
		double p1 = o1.getPrice();
		double p2 = o2.getPrice();

		if (p1 > p2) {
			return 1;
		} else if (p1 < p2) {
			return -1;
		}

		return 0;

	}

}
